/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86187
 * Date: 2022-04-16
 * Time: 15:04
 */

//Scanner scan = new Scanner(System.in);



//求独身数，水仙花数，四叶玫瑰数，五角星数，六和数（1~6位的自幂数）
import java.util.Scanner;

public class TestNode4 {

    public static void main(String[] args) {
        int num = 1;
        int k =0;
        for (int n = 1;n < 999999 ; n++) {

            int sum = 0, count = 0;
            k = n;

            while (k != 0) {
                k = k / 10;
                count++;
            }

            k = n;

            while(k != 0) {
                sum += (int)Math.pow((k%10),count);
                k = k / 10;
            }

            if (sum == n) {
                System.out.print(n + " ");
            }

        }
    }
}
